<h4 class="header">
  <%= _("Latest Errata") %>
</h4>

<% organizations = Organization.current.present? ? [Organization.current] : User.current.allowed_organizations %>
<% hosts = ::Host::Managed.authorized("view_hosts") %>
<% errata = Katello::Erratum.applicable_to_hosts_dashboard(hosts) %>

<% if errata.empty? %>
  <p class="ca"><%= _("There are no errata that need to be applied to registered content hosts.") %></p>
<% else %>
  <table class="table table-fixed table-striped">
    <thead>
      <tr>
        <th class='ellipsis'><%= _("Type") %></th>
        <th class='ellipsis'><%= _("Errata") %></th>
      </tr>
    </thead>
    <tbody>
      <% errata.each do |erratum| %>
        <% hosts = erratum.hosts_applicable %>

        <tr>
          <td class="ellipsis" title="<%= erratum.errata_type %>"><%= erratum.errata_type %></td>
          <td class="ellipsis">
            <a href="/errata/<%= erratum.pulp_id %>">
              <%= erratum.errata_id %> (<%= n_("%s Host", "%s Hosts", hosts.length) % hosts.length %>)
            </a>
          </td>
        </tr>

      <% end %>
    </tbody>
  </table>
<% end %>
